class Watcher {
  constructor(vm, key, cb) {
    this.vm = vm
    this.key = key
    this.cb = cb

    Dep.target = this
    this.oldValue = tools.getChainValue(this.vm, this.key)
    Dep.target = null
  }

  update() {
    let newValue = tools.getChainValue(this.vm, this.key)
    if (newValue === this.oldValue) return
    this.cb && this.cb(newValue)
  }
}